package com.irs.irsforum.web;


import com.irs.irsforum.entity.Problem;
import com.irs.irsforum.entity.Subject;
import com.irs.irsforum.security.access.Access;
import com.irs.irsforum.security.access.UserType;
import com.irs.irsforum.service.IProblemService;
import com.irs.irsforum.service.ISubjectService;
import com.irs.irsforum.web.common.ResponseResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yihuili
 * @since 2020-02-13
 */
@RestController
@RequestMapping("/problem")
public class ProblemController {
    private static final Logger logger =
            LoggerFactory.getLogger(ProblemController.class);

    @Autowired
    IProblemService iProblemService;

    /**
     * 发帖时显示problem列表
     * @return
     */
    @Access(userType = {UserType.LOGIN_USER})
    @RequestMapping(value = "/showproblem", method = RequestMethod.POST)
    public Object showProblem(@RequestParam(value = "subjectId") Long subjectId) {
        logger.info("发帖时显示problem列表");
        List<Problem> problemList = iProblemService.getProblemList(subjectId);
        return ResponseResult.newSuccessResult(problemList);
    }
}

